/*
 * SetDialog.cpp
 *
 *  Created on: 2011-11-16
 *      Author: liangx
 */

#include "SetDialog.h"

SetDialog::SetDialog(QWidget *parent): QDialog(parent) {
	btnRadioComputer = new QRadioButton("Computer First",this);
	btnRadioPlayer = new QRadioButton("Player First",this);
	btnApply = new QPushButton(this);
	btnRadioComputer->setGeometry(QRect(10,10,140,15));
	btnRadioPlayer->setGeometry(QRect(150,10,140,15));
	QLabel* diffTxt = new QLabel(this);
	diffTxt->setText(tr("Difficult Level:"));
	diffTxt->setGeometry(QRect(10,30,140,15));
	difficult = new QSlider(Qt::Horizontal,this);
	difficult->setGeometry(QRect(130,30,140,15));
	difficult->setRange(5,20);
	difficult->setValue(20);
	QLabel* sizeTxt = new QLabel(this);
	sizeTxt->setText(tr("BoardSize:"));
	sizeTxt->setGeometry(QRect(10,50,140,15));
	sizeBox = new QSpinBox(this);
	sizeBox->setGeometry(QRect(130,50,140,30));
	sizeBox->setRange(4,10);
	sizeBox->setValue(4);

	btnApply->setGeometry(QRect(10,170, 93, 27));
	btnApply->setText(tr("Apply"));

	this->setGeometry(QRect(10,10,300,300));

	QObject::connect(btnRadioComputer,SIGNAL(clicked(bool)),this,SLOT(setComputerFirst()));
	QObject::connect(btnRadioPlayer,SIGNAL(clicked()),this,SLOT(setPlayerFirst()));
	QObject::connect(difficult,SIGNAL(valueChanged(int)),this,SLOT(changeDifficultLevel(int)));
	QObject::connect(sizeBox,SIGNAL(valueChanged(int)),this,SLOT(changeBoardSize(int)));

}
/**
 * who goes first,
 * @param n true->human,false computer
 */
void SetDialog::setPlayerFirst(){
	this->setting.playFirst = true;
}
void SetDialog::setComputerFirst(){
	this->setting.playFirst = false;
}

void SetDialog::changeBoardSize(int n){
	this->setting.boardSize = n;
}
void SetDialog::changeDifficultLevel(int n){
	this->setting.difficultLevel = n;
}
